package de.sordul.model;

/**
 * Represents a data entry returned by the eGK. It consists of the data itself and a return code.
 */
public class RawData {
	byte[] data = null;
	byte[] responseCode = null;

	/**
	 * Default constructor. Takes a response as input.
	 * @param entry eGK response
	 */
	public RawData(byte[] entry) {		
		
		// No data, just note the response code
		if(entry.length <= 2) {
			responseCode = entry;
		
		// Data and response code, split in the two fields
		} else {
			data = new byte[entry.length-2];
			System.arraycopy(entry, 0, data, 0, entry.length-2);
			
			responseCode = new byte[2];
			System.arraycopy(entry, entry.length-2, responseCode, 0, 2);
		}
	}
	
	/**
	 * Getter for the data
	 * @return Data
	 */
	public byte[] getData() {
		return data;
	}
	
	/**
	 * Getter for the response code
	 * @return Response code
	 */
	public byte[] getResponseCode() {
		return responseCode;
	}
}
